package pub.guoxin.oops.common.protocol.adapter;

import lombok.Getter;
import lombok.Setter;
import pub.guoxin.oops.common.protocol.builder.DataProtocolCodeRegister;
import pub.guoxin.oops.common.protocol.entity.map.DataProtocolCodeMap;

/**
 * Created by guoxin on 18-3-8.
 */
@Getter
@Setter
public abstract class AbstractDataProtocolCodeAdapter {

    private DataProtocolCodeMap dataProtocolCodeMap = DataProtocolCodeMap.newDataProtocolCodeMap();

    public abstract DataProtocolCodeRegister register(DataProtocolCodeRegister register);

    private DataProtocolCodeRegister register0(DataProtocolCodeRegister register) {
        DataProtocolCodeRegister result = register(register);
        this.dataProtocolCodeMap.putAll(result.getRegister());
        return result;
    }

    public DataProtocolCodeMap build() {
        this.register0(new DataProtocolCodeRegister());
        return dataProtocolCodeMap;
    }
}
